package Domestic;
class FixedStack implements InStack{
	private int stack[];
	private int tos;
	
	FixedStack(int size){
		stack = new int[size];
		tos = -1;
	}
	public void push(int item){
		if(tos == stack.length-1)
			System.out.println("Stack OverFlow");
		else 
			stack[++tos] = item;
	}
	public int pop(){
		if(tos<0){
			System.out.println("Stack UnderFlow");
			return 0;
		}
		else
			return stack[tos--];
	}
}
public class StackInterface {
	public static void main(String[] args){
		FixedStack myStack1 = new FixedStack(5);
		FixedStack myStack2 = new FixedStack(8);
		
		for(int i = 1; i<=5;i++)
			myStack1.push(i);
		for(int i = 1; i<=8;i++)
			myStack2.push(i);
		
		System.out.println("Stack in myStack1 Object");
		for (int i=1;i<=5;i++)
			System.out.println(myStack1.pop());
		
		System.out.println("Stack in myStack2 Object");
		for (int i=1;i<=8;i++)
			System.out.println(myStack2.pop());
	}

}
